'use strict';

const BaseModel = require('./BaseModel');

/**
 * 系统参数 表信息
 */
class SysParamsModel extends BaseModel {

  constructor() {
    super('sys_params', 'id');
    this.entity = class entity {
      constructor() {
        this.id = null;
        this.code = null;
        this.data = null;
        this.type = null;
        this.des = null;
        this.isServer = null;
      }
    };
  }

  async selectAll(app) {
    const sql = `select code,data,type,des from ${this.tableName} where is_server = 0`;
    app.logger.debug('SQL:', sql);
    const results = await app.mysql.query(sql);

    if (results && results.length > 0) {
      const sysMenusList = [];
      for (const sysMenu of results) {
        let entity = new this.entity();
        entity = this.transformation_Entity(sysMenu);
        sysMenusList.push(entity);
      }
      return sysMenusList;
    }
    return null;
  }

}

module.exports = SysParamsModel;
